<template>
   <section class="jumbotron">
      <h3 class="jumbotron-heading">Search Github Users</h3>
      <div>
        <input v-model="keyword" type="text" placeholder="enter the name you search"/>&nbsp;
        <button @click="searchUser" >Search</button>
      </div>
    </section>
</template>

<script>
import axios from 'axios'
export default {
    name:"MySearch",
    data(){
        return {
            keyword:''
        }
    },
    methods: {
        searchUser(){
            // 搜索前的设置
            this.$bus.$emit('updateLists',
            false,true,'',[])
            axios
            .get(`https://api.github.com/search/users?q=${this.keyword}`)
            .then(success=>{
                // console.log(success.data.items);
                this.$bus.$emit('updateLists',
                false,false,'',
                success.data.items)
            },reject=>{
                this.$bus.$emit('updateLists',
                false,false,reject.message,
                [])
            })
        }
    },
}
</script>

<style>

</style>